#!/bin/bash
#

string="kepler kepler wsk wsk aaa"

function print_tips
{
	echo "********************"
	echo "(1) print string length"
	echo "(2) delete string all wsk "
	echo "(3) replace first wsk to wangshengkai"
	echo "(4) replace all wsk to wangshengkai"
	echo "********************"
}

function len_of_string
{
	echo "${#string}"
}

function del_wsk
{
	echo "${string//wsk/}"
}

function replace_first_wsk_to_wangshengkai
{
	echo "${string/wsk/wangshengkai}"
}

function replace_all_wsk_to_wangshengkai
{
	echo "${string//wsk/wangshengkai}"
}

while true
do
	echo "[string=$string]"
	echo
	print_tips
	read -p "please input your choice (1|2|3|4|q|Q): " choice
	
	case $choice in
		1)
			len_of_string
			;;
		2)
			del_wsk
			;;
		3)
			replace_first_wsk_to_wangshengkai
			;;
		4)
			replace_all_wsk_to_wangshengkai
			;;
		q|Q)
			exit
			;;
		*)
			echo "Error, input only in (1|2|3|4|q|Q)"
			;;
	esac
done
